#include<bits/stdc++.h>
using namespace std;
const int N=1e5+3;
int T,n,m,l,v0;
int d[N],v[N],a[N],p[N],b[N];
double vt;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        int ans=0,ans2=0,f=0;
        cin>>n>>m>>l>>v0;
        for(int i=1;i<=m;i++)b[i]=1;
        for(int i=1;i<=n;i++)scanf("%d%d%d",&d[i],&v[i],&a[i]);
        for(int i=1;i<=m;i++)scanf("%d",&p[i]);
        for(int i=1;i<=n;i++){
            if(p[m]<d[i])continue;
            if(a[i]>0){
                vt=sqrt(pow(v[i],2)+2*a[i]*(p[m]-d[i]));
                if(vt>v0){
                    f=1;
                    ans++;
                    b[m]=0;
                }
            }else if(a[i]<0){
                int k=1;
                while(p[k]<d[i])k++;
                vt=sqrt(pow(v[i],2)+2*a[i]*(p[k]-d[i]));
                if(vt>v0){
                    f=1;
                    ans++;
                    b[k]=0;
                }
            }else if(v[i]>v0)ans++;
        }
        for(int i=1;i<=m;i++)ans2+=b[i];
        if(f==0&&ans!=0)ans2=1;
        cout<<ans<<" "<<ans2<<endl;
    }
    return 0;
}
